Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#988: Improved error message from CTPG parser. #466

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

tomuben
Copy link
Collaborator

@tomuben tomuben commented Oct 22, 2024

related to exasol/script-languages-release#988

Also fixes a bug in the parser implementation which could have passed more than one line to the parser.

@tomuben tomuben force-pushed the bug/988_improve_error_message_from_ctpg_parser branch from d0cc304 to 7cc7bd5 Compare October 22, 2024 13:37
Comment on lines +239 to +240
std::string line = code.substr(currentLinePositions->mStartPos,
currentLinePositions->mEndPos - currentLinePositions->mStartPos);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually a bug.
It's std::string::subst(begin, length), not std::string::subst(begin, end)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change something on the performance?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here results of our performance tests:
Master branch: 6.9s
This branch: 7.0s

Comment on lines +93 to 109
TEST(ScriptOptionLinesTest, need_option_termination_character_second_line) {
const std::string code =
"%optionA myoption;\n"
"%optionB myoption\n"
"\nmycode";
options_map_t result;
EXPECT_THROW({
try
{
parseOptions(code, result);
}
catch( const OptionParserException& e )
{
// and this tests that it has the correct message
EXPECT_STREQ( e.what(), "Error parsing script options at line 1: [1:18] PARSE: Syntax error: Unexpected '<eof>'\n");
throw;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider spliting the test into two test.
(try catch within the EXPECT_THROW lets my spidy sense tingle ;P )

  1. Tests if the exception is thrown
  2. Tests if the error message is the expected one

@Nicoretti Nicoretti self-requested a review October 22, 2024 14:36
@tomuben tomuben merged commit 0bd6856 into master Oct 22, 2024
23 of 24 checks passed
@tomuben tomuben deleted the bug/988_improve_error_message_from_ctpg_parser branch October 22, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants